#include <iostream>
using std::cout;
using std::endl;

class A{
protected:
    int _ia;
public:
    A()
    {
        cout << "A()" << endl;
    }

    A(int ia)
        :_ia(ia)
    {
        cout << "A(int)" << endl;
    }

    void f()
    {
        cout << "A::f()" << endl;
    }
};

class B
: virtual public A
//: public A
{
protected:
    int _ib;
public:
    B()
    {
        cout << "B()" << endl;
    }

    B(int ia, int ib)
    :A(ia)
    ,_ib(ib)
    {
        cout << "B(int, int)" << endl;
    }
};

class C
: public B
{
private:
    int _ic;
public:
    C(int ia, int ib, int ic)
        //:A(ia)
        //,B(ia, ib)
        //,_ic(ic)
        :B(ia, ib)
        ,_ic(ic)
    {
        cout << "C(int, int, int)" << endl;
    }

    void show() const
    {
        cout << "_ia: " << _ia << endl
             << "_ib: " << _ib << endl
             << "_ic: " << _ic << endl;
    }
};

void test(){
    C c(10, 20, 30);
    c.show();
    // 无virtual继承版本：_ia:10, _ib:20, _ic:30
    // 流程：C有参调用B有参，B有参调用A有参
    
    // 有virtual继承版本：_ia:0 , _ib:20, _ic:30
    // 流程：C有参调用B有参，B有参调用A无参
    // 虚基类A的初始化也应该写在C处，如注释 :A(ia)
}

int main()
{
    test();
    return 0;
}

